﻿// 1.1.4.09. Write a program that reads the coefficients a, b and c of a
// quadratic equation ax2+bx+c=0 and solves it (prints its real roots).

using System;

class QuadraticEquation
{
    static void Main()
    {
        Console.Write("Please enter the \"a\" coefficient of a quadratic equation: ");
        int a = int.Parse(Console.ReadLine());
        Console.Write("Please enter the \"b\" coefficient of a quadratic equation: ");
        int b = int.Parse(Console.ReadLine());
        Console.Write("Please enter the \"c\" coefficient of a quadratic equation: ");
        int c = int.Parse(Console.ReadLine());
        if (a == 0)
        {
            Console.WriteLine("x = {0}", (c / -1) / b);
        }
        else
        {
            if ((b * b) - (4 * a * c) > 0)
            {
                Console.WriteLine("x1 = {0}", -b + Math.Sqrt(((b * b) - (4 * a * c)) / (2 * a)));
                Console.WriteLine("x2 = {0}", -b - Math.Sqrt(((b * b) - (4 * a * c)) / (2 * a)));
            }
            if ((b * b) - (4 * a * c) == 0)
            {
                Console.WriteLine("x1 = {0}", -b / (2 * a));
            }
            if ((b * b) - (4 * a * c) < 0)
            {
                Console.WriteLine("The equation does not have roots.");
            }
        }
    }
}